﻿using System.Text.Json;
using System.Text.Json.Serialization;

namespace Grow.Json.Text.Parse
{
    public class IntParse : JsonConverter<int>
    {
        public override int Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            bool flag = reader.TryGetInt32(out int value);
            return flag == true ? value : default;
        }

        public override void Write(Utf8JsonWriter writer, int value, JsonSerializerOptions options)
        {
            writer.WriteNumberValue(value);
        }
    }
}
